﻿using System;
using System.Collections.Generic;
using System.Text;
using AspNetCs.Model;
using AspNetCs.Common;
using AspNetCs.IDAL;
using AspNetCs.Enumerations;
using System.Data;
using System.Data.SqlClient;

namespace AspNetCs.SQLServerDAL
{
    public class AncestralHallBBSReplyMsg_DAL:IAncestralHallBBSReplyMsg
    {
        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public int Add(AncestralHallBBSReplyMsgModel model)
        {
            int count = 0;
            db.ParameterArry[] paras = new db.ParameterArry[4];

            paras[0].dbType = SqlDbType.Int;
            paras[0].parName = "@AncestralHallBBSMsgId";
            paras[0].objValue = model.AncestralHallBBSMsgId;

            paras[1].dbType = SqlDbType.Text;
            paras[1].parName = "@Content";
            paras[1].objValue = model.Content;

            paras[2].dbType = SqlDbType.DateTime;
            paras[2].parName = "@PublishTime";
            paras[2].objValue = model.PublishTime;

            paras[3].dbType = SqlDbType.Int;
            paras[3].parName = "@UserId";
            paras[3].objValue = model.UserId;

            string cmdText = "insert into AncestralHallBBSReplyMsg values (@AncestralHallBBSMsgId,@Content,@PublishTime,@UserId)";
            db dbclass = new db();
            count = dbclass.ExcSql(cmdText, paras);

            return count;
        }


        public DataTable GetDataTable(string queryProperties, string filter)
        {
            DataTable dataTable = new DataTable();
            string cmdText = "select {0} from AncestralHallBBSReplyMsg where {1}";
            cmdText = string.Format(cmdText, queryProperties, filter);
            db dbclass = new db();
            dataTable = dbclass.GetSql_DataTable(cmdText);
            return dataTable;
        }


        public int Delete(string filter)
        {
            int count = 0;
            string cmdText = "delete from AncestralHallBBSReplyMsg where {0}";
            cmdText = string.Format(cmdText, filter);
            db dbclass = new db();
            count = dbclass.ExcSql(cmdText);
            return count;
        }
    }
}
